<template>
    <div class="mine-box">
        <plateform-info-view :plateinfo="platformInfo" class="plateform-info-view"></plateform-info-view>
        <div>
            <headquarters-view :headquartersInfo="headquartersInfo" class="headquarters-view"></headquarters-view>
            <mine-info-view :userinfo="userinfo" class="mine-info-view"></mine-info-view>
        </div>
        <platform-data-view :plateNuminfo="plateNuminfo" :table-data="platformData" class="plateform-data-view"></platform-data-view>

    </div>
</template>
<script>
import PlateformInfoView from '@/components/mine/PlatformInfoView.vue';
import HeadquartersView from '@/components/mine/HeadquartersView.vue';
import MineInfoView from '@/components/mine/MineInfoView.vue';
import PlatformDataView from '@/components/mine/PlatformDataView.vue';
import LOCAL from '@/main'
import API from "@/utils/request";

export default {
    data() {
        return {
            LOCAL,
            platformInfo: {
                img: 'img/mine/def_img.jpg',
                tag: '去认证',
                address: '平台地址',
                name: '平台名称',
                email: '平台电子邮箱',
                phone: '平台联系电话',
                scale: '平台规模',
                industry: '平台所属行业'
            },
            platformData:[],
            userinfo: {
                userId: 1001011,
                nicname: '用户昵称',
                phone: '2549455880@qq.com',
                account: '19502503453'
            },
            headquartersInfo: {
                sale: '1000',
                useTo: '传媒',
                industry: '广东省',
                count: '深圳市',
            },
            plateNuminfo: {
                primaryTitle: "平台数",
                primaryNum: 131400,
                secondaryTitle: "投放数",
                secondaryNum: 1254511
            }
        }
    },
    methods: {
        loadPlatformInfo() {
            this.plateNuminfo.primaryNum = 0;
            this.plateNuminfo.secondaryNum = 0;
            API.getBikePlatformCount((res) => {
                if (res.code === 200) {
                    this.platformData = res.data;
                    this.plateNuminfo.primaryNum = res.data.length;
                    for (let i = 0; i < res.data.length; i++) {
                        this.plateNuminfo.secondaryNum += res.data[i].count;
                    }
                }
            })
        },
        loadPlatformInfoByUserId() {
            var userId = localStorage.getItem("USER_ID");
            API.getPlatformInfoByUserId({userId:userId},(res)=>{
                if(res.code === 200){
                    console.log(res.data[0],">>>>>>拿到的平台信息")
                    this.platformInfo = res.data[0];
                    this.headquartersInfo = res.data[0];
                }
            })
        }
    },
    mounted() {
        LOCAL.CHI = false;
        LOCAL.TITLE_INFO = "我";
        LOCAL.MAIN_ACTION_INDEX = 3;
        this.loadPlatformInfo();
        this.loadPlatformInfoByUserId();
    },
    components: {
        PlateformInfoView,
        HeadquartersView,
        MineInfoView,
        PlatformDataView
    },
    // 组件的逻辑代码
}
</script>
<style>
.plateform-info-view {
    margin-top: 10px;
}

.headquarters-view {
    margin-left: 10px;
    margin-top: 10px;
}

.mine-info-view {
    margin-left: 10px;
    margin-top: 10px;
}

.plateform-data-view {
    margin-top: 10px;
    margin-left: 10px;
}

.mine-box {
    position: relative;
    display: inline-flex;
    margin-left: 10px;
}
</style>